package com.example.demo2022.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo2022.entity.User;
import com.example.demo2022.mapper.UserMapper;
import com.example.demo2022.service.IUserService;
import com.example.demo2022.vo.UserRoleVo;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/************************************
 * @PACKAGE : com.example.demo2022.service.impl
 * @Author    :  叫我老伯
 * @Date    : 2022/5/30 21:51
 * @Desc    :
 ***********************************/
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
    @Override
    public void updateUserRoles(UserRoleVo userRoleVo) {
        //多对多关联表的更新
        //1、先删除原有数据
        this.baseMapper.deleteUserRoleByUserId(userRoleVo.getUserId());
        //2、插入新数据
       // List<UserRoleVo> userRoleVoList = new ArrayList<>();
        this.baseMapper.insertBatchUserRole(userRoleVo);

    }
}
